﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using System.IO;
using Moki;
using Moki.Examples.Model;
using System.Xml;

namespace Moki.Examples
{
    [TestFixture]
    class MokiMocks
    {
        [Test]
        public static void LooseMock()
        {
            var database = Mock.Create<IBookingDB>(CallConstraints.Loose); // loose is default

            Show show = new Show();
            Booking booking = database.GetBooking(show, 10); // returns default value

            Assert.AreEqual(null, booking);
        }

        [Test]
        [ExpectedException]
        public static void StrictMock()
        {
            var database = Mock.Create<IBookingDB>(CallConstraints.Strict);

            Show show = new Show();

            Booking booking = database.GetBooking(show, 10); // throws exception
        }

        [Test]
        public static void PartialMock()
        {
            int seed = DateTime.Now.Millisecond;

            Random random = Mock.Create<Random>(seed);
            
        }

        [Test]
        public static void MultiMock()
        {
            Rectangle figure = Mock.Create<Rectangle, IFigure, ICloneable>();

            object figureClone = ((ICloneable)figure).Clone();
            int sides = ((IFigure)figure).Sides;
        }

        [Test]
        public static void AutomaticMock()
        {
            IPerson person = Mock.Create<IPerson>();

            Mock.WhenGet(() => person.Contact.Address.City).Returns("Wroclaw");

            Assert.AreEqual("Wroclaw", person.Contact.Address.City);
        }
    }
}
